/*******************************************************************
 *
 * Copyright (C), 2021-2022, Letstrong, All rights reserved.
 *
 * Author      : 
 * Create Time : 2020-12-14
 * Version     : v0.1
 * Description : 
 *******************************************************************/

#ifndef _OTA_TASK_H_
#define _OTA_TASK_H_


#include "rwprf_config.h"
#if (BLE_OTA_SERVER)
#include <stdint.h>
#include "prf_types.h"
#include "rwip_task.h" // Task definitions

/*
 * DEFINES
 ****************************************************************************************
 */

///Maximum number of  Server task instances
#define OTA_IDX_MAX     0x01
#define OTA_TRANSFER_DATA_MAX_LEN  20

/*
 * TYPE DEFINITIONS
 ****************************************************************************************
 */
 

/// Possible states of the ota task
enum ota_state
{
    /// Idle state
    OTA_IDLE,
    /// busy state
    OTA_BUSY,
    /// Number of defined states.
    OTA_STATE_MAX
};


/// Messages for OTA Server
enum ota_msg_id
{
	/// Start the OTA profile - at connection used 
	OTA_ENABLE_REQ   = TASK_FIRST_MSG(TASK_ID_OTA),
};


/// Features Flag Masks
enum ota_features
{
    ///  Characteristic doesn't support notifications
    OTA_NTF_NOT_SUP,
    OTA_NTF_SUP,
};

/*
 * APIs Structures
 ****************************************************************************************
 */
/// Parameters for the database creation
struct ota_db_cfg
{
	/// Number of  to add
	uint8_t ota_nb;
	/// Features of each  instance
	uint8_t features;
};

///Parameters of the @ref OTA_PACKET_WRITE_REQ message
struct ota_write_req
{
    /// instance
    uint8_t conidx;
	uint8_t len;
    uint8_t value[OTA_TRANSFER_DATA_MAX_LEN];
};

///Parameters of the @ref OTA_CTRL_POINT_NOTIFY message
struct ota_ctrl_point_ntf
{
    /// instance
    uint8_t conidx;
	uint8_t len;
    uint8_t value[OTA_TRANSFER_DATA_MAX_LEN];
};


/*
 * TASK DESCRIPTOR DECLARATIONS
 ****************************************************************************************
 */

extern const struct ke_state_handler ota_default_handler;
#endif // BLE_BRACELET_REPORTER


#endif /* _OTA_TASK_H_ */

